﻿<Window x:Class="Avalon.Window2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window2" Height="300" Width="300">
    <Button Margin="15" Width="200" Name="myButton">
        Click Me to Animate Drop Shadow!
        <Button.BitmapEffect>

            <!-- This BitmapEffect is targeted by the animation. -->
            <DropShadowBitmapEffect x:Name="myDropShadowBitmapEffect" Color="Black" ShadowDepth="0" />
        </Button.BitmapEffect>
        <Button.Triggers>
            <EventTrigger RoutedEvent="Button.Click">
                <BeginStoryboard>
                    <Storyboard>

                        <!-- Animate the movement of the button. -->
                        <ThicknessAnimation
               Storyboard.TargetProperty="Margin" Duration="0:0:0.5"
               From="50,50,50,50" To="0,0,50,50" AutoReverse="True" />

                        <!-- Animate shadow depth of the effect. -->
                        <DoubleAnimation
               Storyboard.TargetName="myDropShadowBitmapEffect"
               Storyboard.TargetProperty="ShadowDepth"
               From="0" To="30" Duration="0:0:0.5"
               AutoReverse="True" />

                        <!-- Animate shadow softness of the effect. As
                   the Button appears to get farther from the shadow, 
                   the shadow gets softer. -->
                        <DoubleAnimation
               Storyboard.TargetName="myDropShadowBitmapEffect"
               Storyboard.TargetProperty="Softness"
               From="0" To="1" Duration="0:0:0.5"
               AutoReverse="True" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Button.Triggers>
    </Button>
</Window>
